<template>
	<view class="container">
		<view class="select-plate">
			皖AN7A2
		</view>
		<view class="box">
			<view class="minibox">
				<view class="title">进场时间:</view>
				<view class="title">{{listdata.in_time}}</view>
			</view>
			<view class="minibox">
				<view class="title">停车时间 :</view>
				<view class="title">{{listdata.duration}}</view>
			</view>
			<view class="minibox">
				<view class="title">免费离场时间（分钟）:</view>
				<view class="title">{{listdata.free_out_time_desc}}</view>
			</view>
			<view class="minibox">
				<view class="title">停车费:</view>
				<view class="title">{{listdata.price}}</view>
			</view>
			<view class="minibox">
				<view class="title">社区信息:</view>
				<view class="title">{{listdata.village_name}}</view>
			</view>
		</view>
		<view class="text"><text style="font-size: 28;">¥</text>{{listdata.price}}</view>
		<button type="primary" :style="btn_style" class="btn" @tap="uPublishTap">立即支付</button>
	</view>
</template>

<script>
	import keyboard from "../component/mpvue-keyboard/mpvue-keyboard.vue";
	var common = require('../../../utils/common.js');
	var app = getApp();
	var _this;
	const gettaskList = () => {
		common.post('HouseApi&a=upload_query_price', {
			village_id: _this.village_id,
			car_number: _this.car_number,
		}, data => {
			console.log('++++', data)
			_this.listdata = data;
			_this.minutes = Number(data.free_out_time);
			_this.totle_price = data.price;
			if (data.price) {
				clearInterval(_this.timer)
			}
			// _this.listdata = data.task_list;
		});
	};
	const getbtnClick = () => {
		common.post('HouseApi&a=park_go_pay', {
			village_id: _this.village_id,
			pigcms_id: _this.pigcms_id,
			money: _this.totle_price,
			car_type:'temporary_type',
			month_end_time: _this.end_time,
			car_id: _this.car_id,
			type: 'park',
		}, data => {
			console.log("nnnnnnn",data)
			common.parseUrl(data.order_url)
		});
	};
	export default {
		data() {
			return {
				listdata: {},
				numlist: {},
				village_id: 0,
				pigcms_id: 0,
				actcolor: '',
				btn_style: '',
				show: true,
				Num: '皖AN7A25',
				nihao: '',
				car_number: '',
				timer: '',
				btnText: '',
				minutes: 10,
				seconds: 0,
				totle_price:'',
			}
		},
		onShow() {
			// #ifdef H5
			common.hideWxShare()
			// #endif
		},
		onLoad(options) {
			_this = this;
			_this.village_id = options.village_id;
			_this.channel_id = options.channel_id;
			_this.car_number = options.car_number;
			console.log("cate_id", _this.cate_id)
			// #ifdef H5
			console.log('准备跳小程序页', _this.id);
			common.webToMiniapp(_this.route, options, 'redirect')
			// #endif

			common.setMainColor(_this, function(config) {
				_this.actcolor = config.config.mobile_head_color
				_this.btn_style = 'background-color: ' + _this.actcolor + ';box-shadow:0px 30rpx 30rpx -30rpx ' + _this.actcolor +
					';';

				const res = uni.getStorageSync('village_key');
				if (res) {
					_this.village_id = res.village_id;
					_this.pigcms_id = res.pigcms_id;
					_this.village_name = res.village_name;
				};
				_this.timer = setInterval(() => {
					gettaskList()
				}, 1000)
			});
		},
		onReady() {

		},
		methods: {
			uPublishTap() {
				getbtnClick()
				// uni.navigateTo({
				// 	url: '/pages/village/smartPark/paymentSuccessful'
				// })
			}
		},
		components: {
			keyboard
		}
	}
</script>

<style>
	page {
		background: #FFFFFF;
	}

	.container {
		margin: 0;
		padding: 0;
		height: 100%;
	}

	.select-plate {
		margin: 30rpx;
		font-size: 32rpx;
		line-height: 100rpx;
		font-weight: 700;
		border-bottom: 2rpx solid #CCCCCC;
	}

	.plate-box {
		margin: 15rpx;
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
		border-bottom: 2rpx solid #F1F1F1;
	}

	.plate {
		padding: 2rpx 10rpx;
		background: #CCCCCC;
		color: rgb(160, 160, 160);
		margin-left: 15rpx;
		margin-top: 15rpx;
	}

	.btn {
		margin: 50rpx;
		border-radius: 50rpx;
	}

	.box {
		margin: 30rpx;
	}

	.minibox {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
	}

	.title {
		font-size: 28rpx;
		line-height: 80rpx;
		color: #999999;
	}

	.text {
		font-size: 32rpx;
		font-weight: 700;
		text-align: center;
	}
</style>
